package com.kmb.provider.service.fallback;

import com.kmb.provider.domain.SfKmUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.List;

/**
 * 用户服务提供者熔断器
 * <p>
 * Description:
 * </p>
 *
 * @see com.kmb.provider.service.fallback
 */
public class SfKmUserServiceFallback {

    private static final Logger logger = LoggerFactory.getLogger(SfKmUserServiceFallback.class);

    /**
     * 熔断方法
     *
     * @param username {@code String} 用户名
     * @param ex       {@code Throwable} 异常信息
     * @return {@link SfKmUser} 熔断后的固定结果
     */
    public static SfKmUser getByUsernameFallback(String username, Throwable ex) {
        logger.warn("Invoke getByUsernameFallback: " + ex.getClass().getTypeName());
        ex.printStackTrace();
        return null;
    }


    public static int addUserFallback(SfKmUser user, Throwable ex) {
        logger.warn("Invoke addUserFallback: " + ex.getClass().getTypeName());
        ex.printStackTrace();
        return 0;
    }

    public static int deleteUserFallback(String userName, Throwable ex) {
        logger.warn("Invoke getByUsernameFallback: " + ex.getClass().getTypeName());
        ex.printStackTrace();
        return 0;
    }

    public static int updatePasswordFallback(String password, String userName, Throwable ex) {
        logger.warn("Invoke updatePasswordFallback: " + ex.getClass().getTypeName());
        ex.printStackTrace();
        return 0;
    }

    public static int importUserFallback(File file, Throwable ex) {
        logger.warn("Invoke importUserFallback: " + ex.getClass().getTypeName());
        ex.printStackTrace();
        return 0;
    }

    public static List<SfKmUser> getUserListFallback(int pageNo, int pageSize, Throwable ex) {
        logger.warn("Invoke getUserListFallback: " + ex.getClass().getTypeName());
        ex.printStackTrace();
        return null;
    }
}
